package MyApp::Workflow::Action::Disagree;

use strict;
use base qw( Workflow::Action );
use Workflow::Exception qw( persist_error );
use Workflow::Factory qw( FACTORY );


sub execute {
	my ($self,$wf) = @_;

	my $db = $wf->context->param('db');
	my ($creator,$workflow_type);
	$workflow_type = $wf->context->param('workflow_type');

	#获取申请单申请人
	$creator = $db->query('select creator from daiban where workflow_id=? and workflow_type=?',$wf->id,$workflow_type)->array->[0];

	#设置下一流程节点处理人
	$db->query('update daiban set agree_user=? where workflow_type=? and workflow_id=?',$creator,$workflow_type,$wf->id);

	$wf->add_history(
		Workflow::History->new(
			{
				action => "驳回",
				description => $wf->context->param('comment'),
				user => $wf->context->param('current_user'),
                                time_zone => 'local'
			}
		)
	);
}

1;
